/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gac.gacmod.visual;

import java.awt.*;
import org.netbeans.api.visual.widget.*;
import org.netbeans.api.visual.action.*;
import org.netbeans.api.visual.widget.LabelWidget.Orientation;
/**
 *
 * @author Tomek
 */
public class ExpandButtonWidget extends ButtonWidget {

    protected IExpandButtonListener _expandListener;
    
    public ExpandButtonWidget(BoxScene scene, IExpandButtonListener listener ) 
    {
        super (scene, ">", null );
        this.setMinimumSize(new Dimension( 10,10));
        _expandListener = listener;
        
        _label.setVerticalAlignment(LabelWidget.VerticalAlignment.BOTTOM);
        _label.setOrientation(Orientation.ROTATE_90);
        
        this.getActions().removeAction(0);
        
        this.getActions().addAction(ActionFactory.createSelectAction( 
                new SelectProvider(){

            public boolean isAimingAllowed(Widget arg0, Point arg1, boolean arg2) {
                return true;
            }

            public boolean isSelectionAllowed(Widget arg0, Point arg1, boolean arg2) {
                return true;
            }

            public void select(Widget arg0, Point arg1, boolean arg2) {
                if( !_expanded )
                {       
                    _label.setLabel(">");
                }
                else
                {
                    _label.setLabel("<");
                }
                
                _expanded = !_expanded;
                if( _expandListener != null )
                   _expandListener.ExpandChanged(_expanded);
            }
        
        }
        ));
            
        }
}
    

